cmake_minimum_required(VERSION 3.4.1)

enable_language(ASM)

set(-DCMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -s -Wdeprecated-declarations")
set(-DCMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -s -Wdeprecated-declarations")
set(PATH_TO_MEDIACORE ${CMAKE_SOURCE_DIR})

add_definitions("
-DGL_GLEXT_PROTOTYPES
-DEGL_EGLEXT_PROTOTYPES
")

if (${ANDROID_PLATFORM_LEVEL} LESS 18)
    add_definitions(-D_OPENGL20_)
    set(OPENGL_LIB GLESv2)
else()
    set(OPENGL_LIB GLESv3)
    add_definitions(-D_OPENGL30_)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    add_definitions(-DVIDEO_DEBUG)
else()
endif()

add_library( # Specifies the name of the library.
        video_recorder

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        source/message_queue.cpp
        source/frame_buffer.cpp
        source/egl_core.cpp
        source/opengl.cpp
        VideoRecorder.cpp)

# Specifies a path to native header files.
include_directories(include/)
include_directories(source/)

find_library( # Defines the name of the path variable that stores the
        # location of the NDK library.
        log-lib

        # Specifies the name of the NDK library that
        # CMake needs to locate.
        log )

# Links your native library against one or more other native libraries.
target_link_libraries( # Specifies the target library.
        video_recorder

        # Links the log library to the target library.
        ${log-lib}
        #log
        android
        GLESv2
        EGL
        z
        mediandk
        OpenSLES)

